<?php

declare(strict_types=1);
/**
 * FastApp.
 * 12/29/24
 * @Author deepsea159
 * @Contact telegram:deepsea159
 */

namespace App\Fastapp\Api\Controller\Account;


use App\Fastapp\Api\Controller\ApiController;
use App\Fastapp\Api\Service\Account\PayInfoService;
use App\Fastapp\Aspect\ApiAuth;
use Hyperf\Di\Annotation\Inject;
use Hyperf\HttpServer\Annotation\Controller;
use Hyperf\HttpServer\Annotation\GetMapping;
use Hyperf\HttpServer\Annotation\PostMapping;
use Psr\Http\Message\ResponseInterface;

#[Controller(prefix: "api/payInfo"), ApiAuth]
class PayInfoController extends ApiController
{
    #[Inject]
    public PayInfoService $service;

    #[GetMapping('list')]
    public function list(): ResponseInterface
    {
        return $this->success($this->service->list($this->request->all()));
    }

    #[PostMapping('create')]
    public function create(): ResponseInterface
    {
        return $this->success($this->service->create($this->validate([
            'type'=>'required|integer',
            'code'=>'string',
            'no'=>'required|string',
            'no_type'=>'string',
            'bank'=>'string',
            'open_bank'=>'string',
        ])));
    }

    #[PostMapping('del')]
    public function del(): ResponseInterface
    {
        return $this->service->del($this->request->input('id')) ? $this->success() : $this->error();
    }
}